package com.junsi.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.junsi.bean.Department;
import com.junsi.mapper.DepartmentMapper;
import com.junsi.service.DepartmentSerivce;

/**
 * 部门Serivce接口实现类
 * @author wkp
 *
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class DepartmentSerivceImpl implements DepartmentSerivce {

	@Autowired
	private DepartmentMapper departmentMapper;
	
	@Override
	public Department findById(Integer id) {
		Department department = departmentMapper.findById(id);
		return department;
	}

	@Override
	public List<Department> findByAll() {
		
		return departmentMapper.findByAll();
	}

	@Override
	public boolean save(Department department) {
		int i = departmentMapper.save(department);
		if(i == 1){
			return true;
		}
		return false;
	}

	@Override
	public boolean update(Department department) {
		int i = departmentMapper.update(department);
		if(i == 1){
			return true;
		}
		return false;
	}

	@Override
	public boolean delete(Integer id) {
		int i = departmentMapper.delete(id);
		if(i == 1){
			return true;
		}
		return false;
	}

	@Override
	public List<Department> findByCompanyId(Integer department_companyId) {
		
		return departmentMapper.findByCompanyId(department_companyId);
	}

	@Override
	public Department findByName(String name) {
		
		return departmentMapper.findByName(name);
	}

	@Override
	public List<Department> findByTop(Integer id) {
		
		return departmentMapper.findByTop(id);
	}

}
